<?php

namespace App\model;

use Illuminate\Database\Eloquent\Model;

/**
 * App\model\UserWorkshop
 *
 * @property int $id
 * @property int|null $workshop_id
 * @property int|null $user_id
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\UserWorkshop newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\UserWorkshop newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\UserWorkshop query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\UserWorkshop whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\UserWorkshop whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\UserWorkshop whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\UserWorkshop whereUserId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\UserWorkshop whereWorkshopId($value)
 * @mixin \Eloquent
 * @property-read \App\model\Workshop|null $workshop
 */
class UserWorkshop extends Model
{
    protected $table="user_workshop";
    public static function getWorkshopIds($user_id){
        $options = \DB::table('user_workshop')->select('workshop_id')->where('user_id',$user_id)->get();
        $selectOption = [];
        foreach ($options as $option){
            $selectOption[] = $option->workshop_id;
        }
        return $selectOption;
    }
    public function workshop(){
        return $this->belongsTo(Workshop::class,'workshop_id');
    }
}
